package com.lmt.base;

import org.springframework.util.StringUtils;

/**
 * 搜索公共属性
 * Date 2018/07/17
 *
 * @author MT-Lin
 */
public class BaseSearch extends BaseRequest {

    /**
     * 实体ID
     */
    private String id;

    /**
     * 名称
     */
    private String designation;

    /**
     * 关键词
     */
    private String keyword;

    /**
     * 当前页
     */
    private int currentPage;

    /**
     * 当前页的记录数目
     */
    private int pageSize;

    /**
     * 总页数
     */
    private int totalPage;

    /**
     * 数据总数
     */
    private int totalElements;

    /**
     * EntityManager查询参数数目
     */
    private int paramsCount;

    public String getKeyword() {
        if (!StringUtils.isEmpty(this.keyword)){
            return "%" + this.keyword + "%";
        } else {
            return this.keyword;
        }
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getDesignation() {
        return designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getCurrentPage() {
        if (currentPage <= 0){
            currentPage = 1;
        }
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getTotalElements() {
        return totalElements;
    }

    public void setTotalElements(int totalElements) {
        this.totalElements = totalElements;
    }

    public int getParamsCount() {
        return paramsCount;
    }

    public void setParamsCount(int paramsCount) {
        this.paramsCount = paramsCount;
    }
}
